﻿using System;
using System.Web;
using System.Web.UI;
using UDS;
using UDS.Entity;
using UDS.Web;

namespace UDS.SubModule.UnitiveDocument.Mail
{
    /// <summary>
    /// Download 的摘要说明。
    /// </summary>
    public class DownloadPage : Page
    {
        protected override void OnInit(EventArgs e)
        {
            int fileID = QSUtil.GetPositiveInt32("FileID");
            MailAttachmentInfo info = null;
            if (fileID > 0)
            {
                info = UDSMail.GetMailAttachment(fileID);
            }

            if (info != null)
            {
                HttpFileResponse response = new HttpFileResponse(Context, HttpUtil.MapPath(info.ResolvedVPath));
                response.ProcessRequest();
            }
            else
            {
                SiteContext.Current.Alert("指定的附件不存在。", "window.close();", true);
            }

            base.OnInit(e);
        }
    }
}
